<template>
	<!-- 修改密码 -->
	<view class="login flex column justify-center items-center">
		<view class="containe w100" v-if="AccountStatus">
			<view class="view form mt-40 mb-90 px-48 flex column justify-center">
				<up-input fontSize="32rpx" color="rgba(0, 0, 0, 0.4)" placeholder="请输入密码" :border="'bottom'"
					v-model="form.oldPassword" :type="showbrowse.showbrowse1?'text':'password'">
					<template #prefix>
						<up-text text="旧密码" margin="0 76px 0 0" type="tips"></up-text>
					</template>
					<template #suffix>
						<image class="pwicon" v-if="showbrowse.showbrowse1" :src="IMG_URL2 + 'login/browse.svg'" @click="changeBrowse(1)" />
						<image class="pwicon" v-else :src="IMG_URL2 + 'login/browse-off.svg'" @click="changeBrowse(1)" />
					</template>
				</up-input>
				<up-input fontSize="32rpx" color="rgba(0, 0, 0, 0.4)" placeholder="请输入密码" :border="'bottom'"
					v-model="form.password" :type="showbrowse.showbrowse2?'text':'password'">
					<template #prefix>
						<up-text text="新密码" margin="0 76px 0 0" type="tips"></up-text>
					</template>
					<template #suffix>
						<image class="pwicon" v-if="showbrowse.showbrowse2" :src="IMG_URL2 + 'login/browse.svg'" @click="changeBrowse(2)" />
						<image class="pwicon" v-else :src="IMG_URL2 + 'login/browse-off.svg'" @click="changeBrowse(2)" />
					</template>
				</up-input>
				<up-input fontSize="32rpx" color="rgba(0, 0, 0, 0.4)" placeholder="请输入密码" :border="'bottom'"
					v-model="form.confirmPassword" :type="showbrowse.showbrowse3?'text':'password'">
					<template #prefix>
						<up-text text="确认新密码" margin="0 46px 0 0" type="tips"></up-text>
					</template>
					<template #suffix>
						<image class="pwicon" v-if="showbrowse.showbrowse3" :src="IMG_URL2 + 'login/browse.svg'" @click="changeBrowse(3)" />
						<image class="pwicon" v-else :src="IMG_URL2 + 'login/browse-off.svg'" @click="changeBrowse(3)" />
					</template>
				</up-input>
			</view>
			<button class="login-btn mt-32 f-32 white" @click="onRegisterFranchisee" :disabled="loading">
				<up-loading-icon class="loading" color="#fff" size="16" :show="loading"></up-loading-icon>
				<text>确认</text>
			</button>
		</view>
		<view v-if="!AccountStatus" class="w100 submitTips">
			<view class="w100 mt-90 flex justify-center items-center flex-wrap">
				<view class="w100 mt-20 flex justify-center items-center"><image class="logo" :src="IMG_URL2+'common/check-circle.svg'" /></view>
				<view class="mt-20 f-24 white titinfo">提交成功，系统审核中</view>
			</view>
			<view class="complete-btn" @click="completeFun">完成</view>
		</view>
	</view>
</template>

<script setup>
import { reactive } from 'vue';
import { IMG_URL2 } from "@/config";
import {  studyApi } from "@/api";

let form = ref({
	oldPassword: '',
	confirmPassword: '',
	password: "",
});
const loading = ref(false);
let AccountStatus = ref(true);
let showbrowse = reactive({
	showbrowse1: false,
	showbrowse2: false,
	showbrowse3: false,
})

onLoad(() => {

});
const changeBrowse = (val) => {
	showbrowse[`showbrowse${val}`] = !showbrowse[`showbrowse${val}`];
};
const onRegisterFranchisee = () => {
	if (form.value.oldPassword.trim() == "") {
		uni.showToast({
			title: "请输入旧密码",
			icon: "none",
			mask: true
		});
		return;
	}
	if (form.value.password.trim() == "") {
		uni.showToast({
			title: "请输入新密码",
			icon: "none",
			mask: true
		});
		return;
	}
	if (form.value.confirmPassword.trim() == "") {
		uni.showToast({
			title: "请输入确认密码",
			icon: "none",
			mask: true
		});
		return;
	}
	loading.value = true;
	studyApi.FRONTSTAFFUPDATEPASSWORD(form.value).then((res) => {
		loading.value = false;
		if (res.code == 200) {
			// AccountStatus.value = false
			uni.showToast({
				title: res.errMsg,
				icon: "none",
				duration: 1000
			});
			uni.switchTab({url: "/pages/index/user"});
		} else {
			uni.showToast({
				title: res.errMsg,
				icon: "none",
				duration: 1000
			});
		}
	});
};

const completeFun = () => {
	uni.switchTab({url: "/pages/index/user"});
}

</script>

<style>
page {
	background-color: #ffffff;
}
</style>
<style lang="scss" scoped>
.login {
	width: 100%;
	.logo {
		width: 160rpx;
		height: 160rpx;
		margin-bottom: 40rpx;
	}

	.titinfo {
		font-family: PingFang SC;
		font-size: 20px;
		font-weight: 600;
		line-height: 28px;
		text-align: center;

	}
	.pwicon{
		width: 48rpx;
		height: 48rpx;
		margin-top: 50rpx;
	}

	.complete-btn{
		background: rgba(253, 236, 219, 1);
		font-family: PingFang SC;
		font-size: 16px;
		font-weight: 600;
		line-height: 24px;
		text-align: center;
		color: rgba(145, 74, 0, 1);

		width: 319px;
		margin:90px auto 0px;
		padding: 12px 20px 12px 20px;
		box-sizing: border-box;
		border-radius: 20px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.login-btn {
		width: 654rpx;
		height: 92rpx;
		line-height: 92rpx;
		background: #D68E44;
		color: #ffffff;
		text-align: center;
		border-radius: 64px;
		font-size: 32rpx;
		display: flex;
    justify-content: center;
	}

	.login-btn:after {
		border: none;
	}


	:deep(.u-input) {
		padding: 0rpx !important;
		background: #ffffff;
	}

	:deep(.u-input__content) {
		height: 100rpx;
		line-height: 100rpx;
	}

	:deep(.uni-input-wrapper) {
		font-size: 32rpx;
	}
	.submitTips{
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 999;
        background-color: rgba(255, 255, 255, 1);
        .submitTipsBox{
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
        .complete-btn{
            background: rgba(253, 236, 219, 1);
            font-family: PingFang SC;
            font-size: 16px;
            font-weight: 600;
            line-height: 24px;
            text-align: center;
            color: rgba(145, 74, 0, 1);

            width: 319px;
            margin:90px auto 0px;
            padding: 12px 20px 12px 20px;
            box-sizing: border-box;
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }

}
</style>